﻿package com.bigstar.lolkor;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import com.google.ads.AdRequest;
import com.google.ads.AdView;

public class ItemMenu2 extends Activity implements OnClickListener{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 
        ChampionData.load(this);
        ItemData.load(this);
        Rune.load(this);
        if(ItemList.type == 0){
            setContentView(R.layout.item_info_defence);
            AdView adview = (AdView)findViewById(R.id.adView);
            AdRequest re = new AdRequest(); 
            adview.loadAd(re);
            Button button = (Button)findViewById(R.id.health_list);
            button.setOnClickListener(this);
            button = (Button)findViewById(R.id.magic_resist_list);
            button.setOnClickListener(this);
            button = (Button)findViewById(R.id.health_regen_list);
            button.setOnClickListener(this);
            button = (Button)findViewById(R.id.armor_list);
            button.setOnClickListener(this);
        }else if(ItemList.type == 1){
            setContentView(R.layout.item_info_attack);
            AdView adview = (AdView)findViewById(R.id.adView);
            AdRequest re = new AdRequest(); 
            adview.loadAd(re);
            Button button = (Button)findViewById(R.id.damage_list);
            button.setOnClickListener(this);
            button = (Button)findViewById(R.id.critical_strike_list);
            button.setOnClickListener(this);
            button = (Button)findViewById(R.id.attack_speed_list);
            button.setOnClickListener(this);
            button = (Button)findViewById(R.id.life_steal_list);
            button.setOnClickListener(this);	
        }else if(ItemList.type == 2){
            setContentView(R.layout.item_info_magic);
            AdView adview = (AdView)findViewById(R.id.adView);
            AdRequest re = new AdRequest(); 
            adview.loadAd(re);
            Button button = (Button)findViewById(R.id.ability_power_list);
            button.setOnClickListener(this);
            button = (Button)findViewById(R.id.cooldown_reduction_list);
            button.setOnClickListener(this);
            button = (Button)findViewById(R.id.mana_list);
            button.setOnClickListener(this);
            button = (Button)findViewById(R.id.mana_regen_list);
            button.setOnClickListener(this);
        }
    }

	@Override
	public void onClick(View v) {
    	Intent intent;
        if(ItemList.type == 0){
        	switch(v.getId()){
        	case R.id.health_list:	ItemList.attr = 0;	break;
        	case R.id.magic_resist_list:	ItemList.attr = 1;	break;
          	case R.id.health_regen_list:	ItemList.attr = 2;	break;
          	case R.id.armor_list:	ItemList.attr = 3;	break;
        	}
        }else if(ItemList.type == 1){
        	switch(v.getId()){
        	case R.id.damage_list:	ItemList.attr = 0;	break;
        	case R.id.critical_strike_list:	ItemList.attr = 1;	break;
          	case R.id.attack_speed_list:	ItemList.attr = 2;	break;
          	case R.id.life_steal_list:	ItemList.attr = 3;	break;
        	}
        }else if(ItemList.type == 2){
        	switch(v.getId()){
        	case R.id.ability_power_list:	ItemList.attr = 0;	break;
        	case R.id.cooldown_reduction_list:	ItemList.attr = 1;	break;
          	case R.id.mana_list:	ItemList.attr = 2;	break;
          	case R.id.mana_regen_list:	ItemList.attr = 3;	break;
        	}
        }
        intent = new Intent(this, ItemList.class);
        if(getIntent().getExtras() != null){
    		intent.putExtra("builder", getIntent().getExtras().getString("builder"));
        }
        this.startActivity(intent);
	}

    @Override
    protected void onResume() {
        ChampionData.load(this);
        ItemData.load(this);
        Rune.load(this);
    	super.onResume();
    	if(Builder.item_select){
        	finish();	
    	}
    }
}
